package com.guigu.tms.security.controller;


import com.guigu.tms.commons.order.entity.vo.Result;
import com.guigu.tms.commons.security.entity.vo.LoginVo;
import com.guigu.tms.security.service.IAuthUserService;
import com.guigu.tms.security.service.IValidateCodeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/manager")
public class ManagerAuthController {



    @Autowired
    private IAuthUserService userService;

    @Autowired
    private IValidateCodeService validateCodeService;

    @PostMapping("login")
    public Result login(@RequestBody LoginVo loginVo, HttpServletResponse response){
        Result loginRes = userService.login(loginVo.getAccount(), loginVo.getPassword(),loginVo.getKey(),loginVo.getValue());
        return loginRes;
    }

    @GetMapping(value = "/createCaptcha")
    public ResponseEntity<Object> captcha(){
        return ResponseEntity.ok(validateCodeService.create());
    }

}
